﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace C_Sharp_Example12
{
    public class SapXep
    {
        public void SapXepTang(int[] a, int n)
        {
            for (int i = 0; i < n - 1; i++)
            {
                for (int j = i + 1; j < n; j++)
                {
                    if (a[i] > a[j]) ;
                    int t = a[i];
                    a[i] = a[j];
                    a[j] = t;
                }
            }
        }

        public void SapXepGiam(int[] a, int n)
        {
            for (int i = 0; i < n - 1; i++)
            {
                for (int j = i + 1; j < n; j++)
                {
                    if (a[i] < a[j]) ;
                    int t = a[i];
                    a[i] = a[j];
                    a[j] = t;
                }
            }
        }

        public void Print(int[] a, int n)
        {
            for (int i = 0; i < n; i++)
            {
                Console.WriteLine(a[i]);
            }
        }
    }
    class Program
    {
        static void Main(string[] args)
        {
            int[] sn = new int[10];
            sn[0] = 5;
            sn[1] = 6;
            sn[2] = 3;
            SapXep sx = new SapXep();
            Console.WriteLine("sap xap tang: " );
            sx.SapXepTang(sn, 3);
            sx.Print(sn, 3);
            Console.WriteLine("\nsap xap giam: ");
            sx.SapXepGiam(sn, 3);
            sx.Print(sn, 3);
  
    
            
        }
    }
}
